<template>
  <div class="container">
    <el-dialog
      @close="close"
      title="题目预览"
      :visible="dialogVisible"
      width="70%"
      modal-append-to-body
    >
      <el-form label-width="82px">
        <el-row>
          <el-col :span="6">
            【题型】：{{
              form.questionType === "1"
                ? "单选题"
                : form.questionType === "2"
                ? "多选题"
                : "简答题"
            }}
          </el-col>
          <el-col :span="6"> 【编号】：{{ form.id }} </el-col>
          <el-col :span="6">
            【难度】：{{
              form.difficulty === "1"
                ? "简单"
                : form.difficulty === "2"
                ? "一般"
                : "困难"
            }}
          </el-col>
          <el-col :span="6"> 【标签】：{{ form.tags }} </el-col>
          <el-col :span="6"> 【学科】：{{ form.subjectname }} </el-col>
          <el-col :span="6"> 【目录】：{{ form.directoryListName }} </el-col>
          <el-col :span="6"> 【方向】：{{ form.direction }} </el-col>
        </el-row>
        <hr />
        <el-row>
          <el-col :span="24"
            >【题干】：
            <span v-html="form.question"></span>
          </el-col>
          <el-col :span="24"
            >{{
              form.questionType === "1"
                ? "单选题"
                : form.questionType === "2"
                ? "多选题"
                : "简答题"
            }}选项：
            <span>（以下选中的选项为正确答案）</span>
            <el-checkbox-group>
              <el-checkbox
              v-show="form.questionType === '2'"
                v-for="item in form.options"
                :label="item.title"
                :key="item.title"
              >{{item.title}}</el-checkbox>
            </el-checkbox-group>
          </el-col>
        </el-row>
        <hr />
        <el-row>
          <el-col>
            【 参考答案】:
            <el-button type="danger" @click="showViodeo=true">视频答案预览</el-button>
            <video v-show="showViodeo" :src="form.viodeoURL"></video>
          </el-col>
        </el-row>
        <hr />
        <el-row>
          <el-col>
            【答案解析】：
            <span v-html="form.answer"></span>
          </el-col>
        </el-row>
        <hr />
        <el-row>
          <el-col :span="24"> 【题目备注】：{{ form.remarks }} </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="close">关闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { detail } from '@/api/hmmm/questions'
export default {
  name: 'QuestionPreview',
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      form: {},
      showViodeo: false
    }
  },

  methods: {
    // 关闭弹框
    close () {
      this.$emit('update:dialogVisible', false)
    },
    // 获取详情
    async articleDetails (id) {
      const { data } = await detail({ id })
      console.log(data)
      this.form = data
    }
  }
}
</script>

<style scoped >
</style>
